package com.dranie.action;

import com.dranie.entity.Category;
import com.dranie.entity.Goods;
import com.jfinal.core.Controller;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: xi
 * Date: 13-8-27
 * Time: PM11:29
 * To change this template use File | Settings | File Templates.
 */
public class WebController extends Controller {


    public void index() {
        setAttr("goodsPage", Goods.dao.paginate(getParaToInt(0, 1), 10, "select * ", " from goods order by id"));
        render("index.html");
    }

    public void detail() {
        Goods g = Goods.dao.findById(getParaToInt());
        if (g.get("imgs") != null) {
            String imgsStr = g.get("imgs").toString().replaceFirst("\\|\\|","");
            String[] imgs = imgsStr.split("\\|\\|");
            g.put("imgList", Arrays.asList(imgs));
        }
        setAttr("goods", g);
        render("detail.html");
    }
}
